<?php

declare(strict_types=1);
/**
 * Created by project.
 * User: huanzipap
 * Date: 2023/5/10
 * Time: 11:25
 */
namespace App\Controller;

use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\RequestMapping;
use App\Libs\Extra\AliOss;

#[Controller(prefix: 'tools')]
class ToolsController extends AppBaseController
{
    //获取阿里云签名
    #[RequestMapping(path:'aliOssSignature',methods: 'get')]
    public function aliOssSignature(): object
    {
        try {
            $dir = $this->request->query('dir',null);
            $sigData = AliOss::getOssSignature($dir);
            return $this->reMsg->re(1,'success', $sigData);
        }catch (\Exception $exception){
            return $this->diyError->errorJson($exception);
        }
    }


    /**
     * 上传图片到服务器
     * @return object
     */
    #[RequestMapping(path:'uploadImage',methods: 'post')]
    public function uploadImage():object
    {
        return $this->upload->uploadImage();
    }

    /**
     * 上传文件到服务器
     * @return object
     */
    #[RequestMapping(path:'uploadFile',methods: 'post')]
    public function uploadFile():object
    {
        var_dump(1111);
        return $this->upload->uploadFile();
    }
}
